package com.example.qt.ptplatform.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.qt.ptplatform.entity.Promotions;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface PromotionsMapper extends BaseMapper<Promotions> {
    // 继承 BaseMapper，提供基本的增、删、改、查功能

    // 根据活动ID查询促销活动
    Promotions selectById(Long promoId);

    /**
     * 查询当前时间内有效的所有促销活动
     * @param currentTime 当前时间
     * @return 有效的促销活动列表
     */
    @Select("SELECT * FROM promotions WHERE p_start_time <= #{currentTime} AND p_end_time >= #{currentTime} ")
    List<Promotions> getActivePromos(LocalDateTime currentTime);
}
